<?php
if (isset($_POST["runquery"])) {
    require 'mysql.php';
    if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    $sql = $_POST['txtquery'];
    if (mysqli_query($link, $sql)) {
        echo "Success.";       
    } else {
        echo "Error" . mysqli_error($link);
    }
}
?>
<html>
    <body>
        <form method="post">
            <textarea rows="4" cols="50" name="txtquery" >Typing query here ...</textarea>
            <br /><br />
            <input type="submit" value="Run Query" name="runquery">
        </form>
    </body>
</html>
